package com.aishang.shopback_2005;

import com.aishang.shopback_2005.intercepter.MySessionIntercepter;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author a1790
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
//    @Resource
//    private MySessionIntercepter mySessionIntercepter;
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(mySessionIntercepter)
//                .addPathPatterns("/**")
//                .excludePathPatterns("/adminUser/login")
//                .excludePathPatterns("/image/**");
//    }
// 注入配置文件中自己指定的静态资源路径和访问路径
@Value("${file.staticAccessPath}")
private String staticAccessPath;
    @Value("${file.uploadFolder}")
    private String uploadFolder;



    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticAccessPath).addResourceLocations("file:" + uploadFolder);
    }


}
